/**
 * Created by Administrator on 2017/3/22 0022.
 */
var Page2={
    create:function()
    {
        var page={};
        var bool_down;
        var startY;
        var downY;
        page.ui=new PIXI.DisplayObjectContainer();

        var bg=new PIXI.Graphics();
        bg.beginFill(0x0,1);
        bg.drawRect(0,0,pixiStageW,pixiStageH);
        bg.endFill();
        page.ui.addChild(bg);

        var glow=new PIXI.Sprite(resource['assets/images/p2_glowLine.png'].texture);
        glow.anchor.set(0.5);
        glow.x=568;
        glow.y=568-150;
        page.ui.addChild(glow);
        TweenMax.to(glow,15,{rotation:Math.PI*2,ease:Linear.easeNone,repeat:-1})

        var img0=new PIXI.Sprite(resource['assets/images/p2_i00.png'].texture);
        img0.anchor.set(0.5);
        img0.x=568;
        img0.y=424;
        page.ui.addChild(img0);
        var img1=new PIXI.Sprite(resource['assets/images/p2_i01.png'].texture);
        img1.anchor.set(0.5);
        img1.x=568;
        img1.y=424;
        page.ui.addChild(img1);

        var line=new PIXI.Sprite(resource['assets/images/p2_line.png'].texture);
        line.anchor.set(0.5);
        line.x=568;
        line.y=424;
        page.ui.addChild(line);

        var t0=new PIXI.Sprite(resource['assets/images/p2_t00.png'].texture);
        t0.anchor.set(0.5);
        t0.x=568;
        t0.y=502;
        page.ui.addChild(t0);

        var t1=new PIXI.Sprite(resource['assets/images/p2_t01.png'].texture);
        t1.anchor.set(0.5);
        t1.x=568;
        t1.y=502;
        page.ui.addChild(t1);


        page.In=function(idx)
        {
            TweenMax.killTweensOf(img0);
            TweenMax.killTweensOf(img1);
            TweenMax.killTweensOf(t0);
            TweenMax.killTweensOf(t1);

            subIdx=idx;

            t0.texture=resource['assets/images/p2_t'+idx+'0.png'].texture;
            t1.texture=resource['assets/images/p2_t'+idx+'1.png'].texture;
            img0.texture=resource['assets/images/p2_i'+idx+'0.png'].texture;
            img1.texture=resource['assets/images/p2_i'+idx+'1.png'].texture;

            bg.alpha=0;
            TweenMax.to(bg,2,{delay:0,alpha:1});

            glow.alpha=0;
            TweenMax.to(glow,2,{delay:0,alpha:1});

            line.scale.x=0;
            TweenMax.to(line.scale,2,{delay:0.5,x:1});

            t0.alpha=0;
            t1.alpha=0;
            TweenMax.to(t0,1.5,{delay:2.5,alpha:1});
            TweenMax.to(t0,1,{delay:6,alpha:0});
            TweenMax.to(t1,1.5,{delay:7,alpha:1});
            TweenMax.to(t1,1,{delay:12,alpha:0,onComplete:function()
            {
               var midx=Math.floor(subIdx+3);
               console.log('midx',midx);
               var event = new CustomEvent("Game_PageIn",{'detail':midx});
                document.dispatchEvent(event);
            }});

            img0.alpha=img1.alpha=0;
            TweenMax.to(img0,1,{alpha:1,repeat:-1,yoyo:true,repeatDelay:0.5,ease:Cubic.easeInOut});
            TweenMax.to(img1,1,{delay:1.5,alpha:1,repeat:-1,yoyo:true,repeatDelay:0.5,ease:Cubic.easeInOut});
            //setTimeout(function()
            //{
            //    TweenMax.to(img0,1,{alpha:0,repeat:-1,repeatDelay:1});
            //},1000);

        }



        return page;
    }

}